package com.aop.zy.aop.service.impl;

import com.aop.zy.aop.annotation.PrintTime;
import com.aop.zy.aop.service.TimeService;
import org.springframework.stereotype.Service;

import java.text.SimpleDateFormat;
import java.util.Date;

/**
 * @author zhangyi
 * @date 2018/12/23 20:42
 */
@Service
public class TimeServiceImpl implements TimeService {

    @Override
    public String printTime() {
        Date date = new Date(System.currentTimeMillis());
        SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd kk:mm:ss");
        String format = dateFormat.format(date);
        System.out.println("在服务实现类中打印时间:"+format);
        this.serviceTest();
        return "将时间返回给Controller层:"+format;
    }

    private void serviceTest(){
        System.out.println("服务类中的方法");
    }
}
